titles = document.getElementsByClassName('titles');
function search(query){
	query = query.toLowerCase();
	len = titles.length;
	for( var i = 0; i < len ; i++ ) {
		current = (titles[i].innerHTML).toLowerCase();
		if(current.indexOf(query) < 0){
			//console.log(current);
			titles[i].parentNode.style.display = "none";
		}else{
			titles[i].parentNode.style.display = "block";
		}
	}
}
$(document).mouseup(function (e)
{
    var container = $("#searchresult, #search");
	var toHide = $("#searchresult");
	
    if (container.has(e.target).length === 0)
    {
        toHide.hide();
    }
});